package com.knowledge.graph.dataSource;

import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Component
public class DataSourceRegistry {

    @Resource
    private CourseSource courseSource;

    private Map<String, DataSource> dataSourceMap;

    @PostConstruct
    public void init() {
        dataSourceMap = new HashMap(){{
            put("courseSource",courseSource);
        }};
    }

    public DataSource getDataSource(String type) {
        if (dataSourceMap.isEmpty()){
            return null;
        }
        return dataSourceMap.get(type);
    }
}
